package org.webdb.jdbc.impl;

import org.webdb.jdbc.JDBCColumn;
import org.webdb.jdbc.JDBCTable;

import com.healthmarketscience.sqlbuilder.BinaryCondition;
import com.healthmarketscience.sqlbuilder.Condition;
import com.healthmarketscience.sqlbuilder.InsertQuery;
import com.healthmarketscience.sqlbuilder.SqlObject;
import com.healthmarketscience.sqlbuilder.dbspec.Table;
import com.healthmarketscience.sqlbuilder.dbspec.basic.DbSpec;

public class SqlAnsi92_SqlProvider extends JDBCAbstractSqlProvider {

    private DbSpec ansiDbSpec;

    public SqlAnsi92_SqlProvider(DbSpec dbSpec) {
        this.ansiDbSpec = dbSpec;
    }

    @Override
    protected DbSpec createDbSpec() {
        return ansiDbSpec;
    }

    @Override
    public InsertQuery createInsertQuery(Table table) {
        return new InsertQuery(table);
    }

    @Override
    protected JDBCSelectQuery createSelectQuery() {
        return new JDBCSelectQuery();
    }

    public Condition eq(JDBCTable table, JDBCColumn column, Object value) {
        return BinaryCondition.equalTo(getColumn(column), value);
    }

    public SqlObject callSequenceNextValue(String sequenceName) {
        // TODO: Fix
        SqlObject sequenceCall = new PGSequenceCall(sequenceName);

        return sequenceCall;
    }

}
